#include <iostream>
#include <thread>
#include <memory>
#include <functional>
#include <future>
using namespace std;


int Add(int x, int y)
{
    return x + y;
}

int main()
{
    auto pack = make_shared<packaged_task<int(int, int)>>(Add);
    future<int> fu = pack->get_future();

    auto func = [pack](){(*pack)(11, 22);};

    thread th(func);


    cout << fu.get() << endl;

    th.join();
    return 0;
}

// int main()
// {
//    packaged_task<int(int, int)> pack(Add);
//     future<int> fu = pack.get_future();

//     auto func = [&pack](){pack(11, 22);};

//     thread th(func);


//     cout << fu.get() << endl;

//     th.join();
//     return 0;
// }